2 REM Computador Personal MS-61
3 REM Programa: BLACMAR1.BAS  - Sistema: JUEGOS
10 REM	**********************************************************
20 REM **    DIRECTORY OF SUBROUTINES  **
30 REM	**   1760  -  Count the hand				**
40 REM	**   1960  -  Drawing the back of a card		**
50 REM	**   2060  -  Splitting a hand				**
60 REM	**   2490  -  Blackjack by the player			**
70 REM	**   2630  -  Blackjack by the dealer			**
80 REM	**   2710  -  Sound effects for the deck shuffle	**
90 REM	**   2770  -  Display the BUST message			**
100 REM **   2840  -  Inputting an answer			**
110 REM **   2910  -  Inputting the bet 			**
120 REM **   3100  -  Displaying the bet			**
130 REM **   3140  -  Updating the players' amounts             **
140 REM **   3260  -  Shuffling the cards			**
150 REM **   3450  -  Drawing the face of a card		**
160 REM **   3740  -  Inputting the insurance amount		**
170 REM **   3900  -  Erasing the screen at lines 15, 16, & 17	**
180 REM **   3960  -  Removing the sign from a dollar amount	**
190 REM **********************************************************
230 Z5=0
240 COMMON NAM$(),PLAYER(),CURRENT,PEOPLE,PRMTXT,SECTXT,TRITXT
250 IF TRITXT=0 THEN BAKGRD=2:FORTXT=16 ELSE IF TRITXT=7 THEN BAKGRD=2:FORTXT=31 ELSE BAKGRD=0:FORTXT=31
255 COLOR PRMTXT,BAKGRD,BAKGRD:CLS
260 TRUE=1: FALSE=0
270 DIM DECK(52), DCARD(11), PCARD(11)
280 GOSUB 3140
290 COLOR SECTXT,BAKGRD
300 REM **  randomize  **
310 DEF SEG=&H40:RANDOMIZE PEEK(&H6D)*256!+PEEK(&H6C)-32768!
315 LOCATE 10,15: COLOR PRMTXT: PRINT "BLACKJACK"
320 GOSUB 3260
330 REM **  main screen  **
335 LOCATE 10,1:PRINT SPACE$(40)
340 COLOR BAKGRD: LOCATE 15,1,0: PRINT SPACE$(40)
350 LOCATE 16,1,0: PRINT SPACE$(40): LOCATE 17,1,0: PRINT SPACE$(40)
360 REM
361 'LOCATE 10,1:PRINT "Modo test? ":A$=INKEY$: IF A$="" THEN 361 ELSE IF A$<>"s" AND A$<>"S" THEN 370
362 'FOR I=CARDNBR+2 TO CARDNBR+4 STEP 2:LOCATE 10,1:PRINT "Entre cartas del tallador:    ":LOCATE 10,23:INPUT DECK(I):CARD=DECK(I):LOCATE 10,30:GOSUB 3560:NEXT
363 'FOR I=1 TO 500:NEXT:LOCATE 10,1:PRINT SPACE$(40)
364 'LOCATE 10,1:PRINT"Entre cartas del jugad.: ";:FOR I=CARDNBR+1 TO CARDNBR+3 STEP 2:LOCATE 10,23:COLOR BAKGRD:PRINT SPACE$(7):COLOR 1:LOCATE 10,23:INPUT DECK(I):CARD=DECK(I):LOCATE 10,30:GOSUB 3560:NEXT
365 'FOR I=1 TO 500:NEXT:LOCATE 10,1:PRINT SPACE$(40)
370 LOCATE 23,5: COLOR PRMTXT: PRINT "Pres. Esc p/retornar al menu";:IF PEOPLE=1 THEN PRINT ".";:GOTO 381 ELSE PRINT ",";
380 LOCATE 24,7,0: PRINT "tipee P p/pasar su turno. ";
381 IF PLAYER(CURRENT)>=10 THEN 399
382 LOCATE 15,7:COLOR SECTXT:PRINT NAM$(CURRENT)", necesita al menos":LOCATE 16,7:PRINT "$10 p/jugar blackjack."
383 LOCATE 18,7,0:PRINT "Quiere probar     ";:LOCATE 19,7,1:PRINT "el Tragamonedas  (S/N)? ";
384 ANS$=INKEY$: IF ANS$<>"" THEN 384
385 ANS$=INKEY$: IF ANS$="" THEN 385
386 IF ANS$="s" OR ANS$="S" THEN COLOR TRITXT:PRINT ANS$;:CHAIN"slotmar1"
387 IF ANS$=CHR$(27) THEN COLOR TRITXT:PRINT "Esc";:CHAIN"rstart",420
388 IF ANS$<>"N" AND ANS$<>"n" THEN SOUND 400,4:GOTO 385
389 COLOR TRITXT:PRINT ANS$;
390 IF PEOPLE=1 THEN CHAIN"rstart",420
393 GOSUB 3900:LOCATE 18,1,0:PRINT SPACE$(40):LOCATE 19,1!:PRINT SPACE$(40):CURRENT=CURRENT+1:IF CURRENT>PEOPLE THEN CURRENT=1
394 GOTO 381
399 LOCATE 15,1,0: COLOR SECTXT: PRINT NAM$(CURRENT)", apueste (Ficha de 10$"
400 PRINT "min: Tipee M para min.)? ";
405 LOCATE 16,25: COLOR TRITXT: PRINT "                 ";: LOCATE 16,25,1
410 GOSUB 2910
420 IF BET<10 THEN  LOCATE 20,3,0: COLOR TRITXT: SOUND 400,4: PRINT NAM$(CURRENT)", 10$ es el minimo.        ": FOR I=1 TO 2000: NEXT: LOCATE 20,3: PRINT SPACE$(37);: GOTO 405
430 IF BET>PLAYER(CURRENT) THEN LOCATE 20,3,0: COLOR TRITXT: SOUND 400,4: PRINT NAM$(CURRENT)", Ud. solo tiene $";: VALU=PLAYER(CURRENT): GOSUB 3960: PRINT A$".":FOR I=1 TO 2000: NEXT: LOCATE 20,3: PRINT SPACE$(37);: GOTO 405
440 GOSUB 3900: LOCATE 23,1: PRINT SPACE$(40);: LOCATE 24,1: PRINT SPACE$(39);
450 PLAYER(CURRENT)=PLAYER(CURRENT)-BET: GOSUB 3140
460 GOSUB 3900: AMO=BET: GOSUB 3100: GOTO 470
470 COLOR SECTXT: LOCATE 14,1,0: PRINT STRING$(40,240)
480 REM **  deal the cards  **
490 NBRCDSP = 0 	'THE NUMBER OF CARDS THE PLAYER HAS INIT TO 0
500 NBRCDSD = 0 	'THE NUMBER OF CARDS THE DEALER HAS INIT TO 0
510 ROW = 15 : COL = 1 : COLP = 1 : COLD = 6
520 DEALTO = 1		'START DEALING TO THE PLAYER
530 IF CARDNBR>50 THEN Z5=1:GOSUB 3280
540 CARDNBR = CARDNBR + 1
550 IF DEALTO=1 THEN NBRCDSP=NBRCDSP+1: PCARD(NBRCDSP)=DECK(CARDNBR): ROW=15 ELSE NBRCDSD=NBRCDSD+1: ROW=7: COL=COLD: DCARD(NBRCDSD)=DECK(CARDNBR)
560 CARD = DECK(CARDNBR)
570 IF NBRCDSD=2 AND DEALTO=0 THEN GOSUB 1960 ELSE GOSUB 3450
580 REM
590 REM DEAL THE NEXT CARD IF ANYONE WANTS ONE.
600 IF NBRCDSD=0 THEN DEALTO=0: GOTO 530
610 IF NBRCDSP=1 THEN DEALTO=1: COL=COLP+4: COLP=COL: COLD=COL+5: GOTO 530
620 IF NBRCDSD=1 THEN DEALTO=0: GOTO 530
630 IF NBRCDSP=2 AND NBRCDSD=2 THEN DEALTO=1
640 IF DEALTO=0 GOTO 1210    'CHECK TO SEE WHO GETS THE NEXT CARD
650 COUNT = 0
660 ACE=FALSE : KING=FALSE : QUEEN=FALSE : JACK=FALSE : TEN=FALSE : NINE=FALSE : EIGHT=FALSE : SEVEN=FALSE : SIX=FALSE : FIVE=FALSE : FOUR=FALSE: THREE=FALSE : TWO = FALSE
670 FOR CNT = 1 TO NBRCDSP
680	CARD = PCARD(CNT)
690	GOSUB 1760
700	IF BUST THEN LOCATE 23,2: COLOR BAKGRD,BAKGRD: PRINT "     ";: LOCATE 23,2:               COLOR SECTXT: PRINT COUNT;: COUNT=0: BST = 1: GOSUB 2770: ROW=7: COL=10:        CARD=DCARD(2): GOSUB 3450: GOTO 1460
710 NEXT
715 IF ACE>0 THEN DDTOTAL=COUNT-10 ELSE DDTOTAL=0
717 IF COUNT=21 AND NBRCDSP>2 THEN DDTOTAL=0:GOSUB 12000:FOR I=1 TO 1500:NEXT:LOCATE 22,10,0:PRINT SPACE$(20):LOCATE 23,10,0:PRINT SPACE$(28):GOTO 1163
720 BLACKJACKP = FALSE
730 IF NBRCDSP=2 AND COUNT=21 THEN BLACKJACKP=TRUE
740 SPLIT = FALSE
750 IF NBRCDSP=2 AND (KING=2 OR QUEEN=2 OR JACK=2 OR (ACE=1 AND COUNT=12) OR TEN=2 OR NINE=2 OR EIGHT=2 OR SEVEN=2 OR SIX=2 OR FIVE=2 OR FOUR=2 OR THREE=2 OR TWO=2) THEN SPLIT=TRUE
760 DD = FALSE
770 IF NBRCDSP=2 AND (COUNT=11 OR COUNT=10 OR DDTOTAL=11 OR DDTOTAL=10) THEN DD=TRUE
780 GOSUB 12000
790 COUNT = 0
800 ACE = FALSE
810 FOR CNT=1 TO 2
820	CARD = DCARD(CNT)
830	GOSUB 1760
840 NEXT
850 TOTLD=COUNT: BLACKJACKD=FALSE
860 IF TOTLD=21 THEN BLACKJACKD=TRUE
870 IF DCARD(1)<>1 AND DCARD(1)<>14 AND DCARD(1)<>27 AND DCARD(1)<>40 GOTO 1040
880 LOCATE 22,13: COLOR BAKGRD,BAKGRD: PRINT SPACE$(27);: LOCATE 23,13: PRINT SPACE$(27);: IF NBRCDSP > 2 OR PLAYER(CURRENT)=0 THEN 1040
890 LOCATE 22,13: COLOR PRMTXT: PRINT "Asegura   (S - N)?     ";
895 LOCATE 22,33: COLOR TRITXT: PRINT "      ";: LOCATE 22,33,1
900 INSUR$=INKEY$: IF INSUR$<>"" THEN 900
910 INSUR$=INKEY$: IF INSUR$=""  THEN 910
920 IF INSUR$<>"S" AND INSUR$<>"s" THEN GOTO 1020
930 PRINT INSUR$;
940 GOSUB 3740
950 IF INS=0 THEN 1040   'asume que el jugador no desea asegurar su apuesta
960 IF INS<=VAL(A$) THEN 970 ELSE LOCATE 25,13,0: SOUND 400,4: PRINT " Sube a $";: PRINT A$", "NAM$(CURRENT)".";: FOR I=1 TO 1500: NEXT: COLOR BAKGRD: LOCATE 25,13: PRINT SPACE$(26);: GOTO 940
970 IF BLACKJACKD THEN TOTLD=21: COUNT=21: COL=10: ROW=7: CARD=DCARD(2): GOSUB 3450: BET=INS*2: GOTO 1450
980 PLAYER(CURRENT)=PLAYER(CURRENT)-INS: GOSUB 3140: DEALER=DEALER+INS
990 COLOR PRMTXT: LOCATE 5,20: PRINT "  Seguro  $";
1000 VALU=INS: GOSUB 3960: PRINT A$;
1010 GOTO 1040
1020 IF INSUR$<>"N" AND INSUR$<>"n" THEN SOUND 400,4: GOTO 895
1030 PRINT INSUR$;
1040 IF BLACKJACKD THEN SPLIT=FALSE: ROW=7: COL=10: CARD=DCARD(2): GOSUB 3450: IF BLACKJACKP GOTO 1450 ELSE GOSUB 2630: GOTO 1390
1050 LOCATE 22,13: COLOR BAKGRD,BAKGRD: PRINT SPACE$(27);: LOCATE 23,13: PRINT SPACE$(27);
1060 IF BLACKJACKP THEN COUNT=21: TOTLD=0: PLAYER(CURRENT)=PLAYER(CURRENT)+INT(BET/2): DEALER=DEALER-INT(BET/2): GOSUB 2490: GOTO 1470
1070 IF DD2 THEN DD2=FALSE: DEALTO=0: CARD=DCARD(2): ROW=7: COL=10: GOSUB 3450: GOTO 1220
1080 COLOR PRMTXT,BAKGRD: LOCATE 22,13: IF (DD=FALSE) AND (SPLIT=FALSE) THEN PRINT "C=CARTA B=BASTA? ";: COLOR TRITXT: PRINT "   ";: LOCATE 22,30,1: GOTO 1145
1110 IF ((BET*2)<=PLAYER(CURRENT)+BET) THEN 1120
1111 SOUND 400,4:LOCATE 24,10:COLOR TRITXT:PRINT "Usted no tiene dinero para  ";:LOCATE 25,10:IF SPLIT=TRUE AND DD=FALSE THEN PRINT "abrirse. ";
1112 IF SPLIT=FALSE AND DD=TRUE THEN PRINT "duplicar apuesta.";
1113 IF SPLIT=TRUE AND DD=TRUE THEN PRINT "duplicar o abrirse.     ";
1114 SPLIT=FALSE:DD=FALSE:FOR I=1 TO 4000:NEXT:FOR I=24 TO 25:LOCATE I,10:COLOR BAKGRD:PRINT SPACE$(32);:NEXT:GOTO 1080
1120 IF DD AND (SPLIT=FALSE) THEN PRINT "C=CARTA B=BASTA": LOCATE 23,14: PRINT "D=DUPLICA POSTURA? ";: COLOR TRITXT: PRINT "  ";: LOCATE 23,33,1: GOTO 1145
1130 IF SPLIT AND (DD=FALSE) THEN PRINT "C=CARTA B=BASTA": LOCATE 23,14: PRINT "A=SE ABRE? ";: COLOR TRITXT: PRINT "  ";: LOCATE 23,23,1: GOTO 1145
1140 IF SPLIT AND DD THEN PRINT "C=CARTA B=BASTA": LOCATE 23,13: PRINT "D=DUPLICA   A=SE ABRE ? ";: COLOR TRITXT: PRINT "  ";: LOCATE 23,37,1
1145 GOSUB 2840
1150 IF ANS$="C" OR ANS$="c" THEN PRINT ANS$;: SPLIT=FALSE: COL=COLP+4: COLP=COL: GOTO 530
1160 IF ANS$<>"B" AND ANS$<>"b" THEN 1170
1161 PRINT ANS$;
1163 IF DDTOTAL<>0 THEN COUNT=DDTOTAL+10:DDTOTAL=0:GOSUB 12000
1165 SPLIT=FALSE: DEALTO=0: CARD=DCARD(2): ROW=7: COL=10: GOSUB 3450: GOTO 1220
1170 IF (ANS$="A" OR ANS$="a") AND SPLIT THEN PRINT ANS$;:SPLIT=2:PLAYER(CURRENT)=PLAYER(CURRENT)-AMO:GOSUB 3140:AMO=AMO*2:GOSUB 3100:GOSUB 2060:COUNT=TOTLP2:DEALTO=0:CARD=DCARD(2):ROW=7:COL=10:GOSUB 3450:IF TOTLP1=-1 AND TOTLP2=-1 THEN 1460 ELSE 1210
1180 IF (ANS$="D" OR ANS$="d") AND DD THEN PRINT ANS$;: PLAYER(CURRENT)=PLAYER(CURRENT)-BET: GOSUB 3140: BET=BET*2: AMO=BET: GOSUB 3100: COL=COLP+4: COLP=COL: DD2=TRUE: GOTO 530
1200 SOUND 400,4: GOTO 1145
1210 REM **  see if the dealer wants more cards  **
1220 COUNT = 0
1230 ACE = FALSE
1240 FOR CNT=1 TO NBRCDSD
1250	CARD = DCARD(CNT)
1260	GOSUB 1760
1270	IF BUST THEN COLOR PRMTXT,BAKGRD: LOCATE 9,1,0: PRINT "TOTAL": LOCATE 10,1,0:        COLOR SECTXT: PRINT COUNT: TOTLD=0: COUNT=1: BST=0: GOSUB 2770:                 GOTO 1470
1280 NEXT
1290 TOTLD=COUNT: BLACKJACKD=FALSE
1300 COLOR PRMTXT,BAKGRD: LOCATE 9,1,0: PRINT "TOTAL": LOCATE 10,1,0: COLOR SECTXT: PRINT TOTLD
1310 IF TOTLD=21 AND NBRCDSD=2 THEN BLACKJACKD=TRUE
1320 IF BLACKJACKD AND BLACKJACKP GOTO 1450
1330 FOR JJ=1 TO 500: NEXT JJ
1340 IF COUNT<17 THEN COL=COLD+4: COLD=COL: GOTO 530
1350 'IF COUNT=17 AND ACE THEN COL=COLD+4: COLD=COL: GOTO 530
1360 TOTLD = COUNT
1370 IF SPLIT=1 THEN COUNT=TOTLP2: GOTO 1450
1380 COUNT = 0
1390 ACE = FALSE
1400 FOR CNT=1 TO NBRCDSP
1410	CARD = PCARD(CNT)
1420	GOSUB 1760
1430	IF BUST THEN COUNT=0: BST=1: GOSUB 2770: GOTO 1460
1440 NEXT
1450 COLOR FORTXT,BAKGRD: IF TOTLD=COUNT THEN PLAYER(CURRENT)=PLAYER(CURRENT)+BET: LOCATE 14,17,0: PRINT "EMPATE": IF (NOT BLACKJACKD) THEN PLAY "MBL32O3AAAAAAAAAAAAAAAA" : IF FIRST=1 THEN 1540 ELSE GOTO 1480    'IT'S A PUSH GO REDEAL
1460 COLOR FORTXT,BAKGRD: IF TOTLD>COUNT THEN LOCATE 14,17,0: PRINT "YO GANO": DEALER=DEALER+BET: IF (BLACKJACKD=FALSE) THEN PLAY "MBL25O5CO4BAGFEDCO3BAGFEDC": GOTO 1480 ELSE GOTO 1480    'DEALER WINS
1470 COLOR FORTXT,BAKGRD: IF TOTLD<COUNT THEN LOCATE 25,16,0: PRINT "UD GANA";: DEALER=DEALER-BET: PLAYER(CURRENT)=PLAYER(CURRENT)+(BET*2): IF (BLACKJACKP=FALSE) THEN PLAY "MBL25O3CDEFGABO4CDEFGABO4C"    'DEALER LOSES
1480 IF SPLIT=0 THEN 1540
1490 FOR I=1 TO 2000: NEXT
1500 COUNT = TOTLP1
1510 COLOR FORTXT,BAKGRD: IF TOTLD=COUNT THEN LOCATE 14,32,0: PRINT "EMPATE": PLAY "MBL32O3AAAAAAAAAAAAAAAA":PLAYER(CURRENT)=PLAYER(CURRENT)+BET: GOTO 1540    'IT'S A PUSH GO REDEAL
1520 IF TOTLD>COUNT THEN LOCATE 14,32,0: PRINT "YO GANO": PLAY "MBL25O5CO4BAGFEDCO3BAGFEDC": DEALER=DEALER+BET: GOTO 1540      'DEALER WINS
1530 IF TOTLD<COUNT THEN LOCATE 25,31,0: PRINT "UD GANA";: PLAY "MBL25O3CDEFGABO4CDEFGABO5C": DEALER=DEALER-BET: PLAYER(CURRENT)=PLAYER(CURRENT)+(BET*2)   'DEALER LOSES
1540 REM **  reset the values before dealing again  **
1550 IF TOTLD=0 THEN 1560 ELSE COLOR PRMTXT,BAKGRD: LOCATE 9,1,0: PRINT "TOTAL": LOCATE 10,1,0: COLOR SECTXT: PRINT TOTLD
1560 FOR X=1 TO 2500: NEXT     'PAUSE SO PLAYER CAN SEE SCORE
1570 IF TOTLD<=COUNT OR SPLIT<>0 THEN GOSUB 3140
1580 COLOR BAKGRD
1590 FOR I = 3 TO 23
1600	LOCATE I,1: PRINT SPACE$(40);
1610 NEXT
1620 FOR I=24 TO 25
1630	LOCATE I,1: PRINT SPACE$(39);
1640 NEXT
1650 IF PLAYER(CURRENT)<1 THEN CHAIN"Rstart",1060
1655 IF PLAYER(CURRENT)>=1000000! THEN CHAIN"Rstart",1105
1660 FOR I=1 TO 11
1670	DCARD(I)=0: PCARD(I)=0
1680 NEXT
1690 IF CARDNBR>42 THEN GOSUB 3260
1695 IF BLACKJACKD=TRUE OR BLACKJACKP=TRUE THEN GOSUB 3260
1700 BLACKJACKD=FALSE: BLACKJACKP=FALSE: BUST=FALSE: DD=FALSE: SPLIT=FALSE
1710 CURRENT=CURRENT+1: IF CURRENT>PEOPLE THEN CURRENT=1
1720 GOSUB 3140: GOTO 361
1730 REM *****************************************************
1740 REM **  COUNT THE HAND THAT THE PLAYER OR DEALER HAVE  **
1750 REM *****************************************************
1760 IF CARD=11 OR CARD=24 OR CARD=37 OR CARD=50 THEN COUNT=COUNT+10: JACK=JACK+1: GOTO 1890
1770 IF CARD=12 OR CARD=25 OR CARD=38 OR CARD=51 THEN COUNT=COUNT+10: QUEEN=QUEEN+1: GOTO 1890
1780 IF CARD=13 OR CARD=26 OR CARD=39 OR CARD=52 THEN COUNT=COUNT+10: KING=KING+1: GOTO 1890
1790 IF CARD=1 OR CARD=14 OR CARD=27 OR CARD=40 THEN COUNT=COUNT+11: ACE=ACE+1: GOTO 1890
1800 IF CARD=2 OR CARD=15 OR CARD=28 OR CARD=41 THEN COUNT=COUNT+2: TWO=TWO+1: GOTO 1890
1810 IF CARD=3 OR CARD=16 OR CARD=29 OR CARD=42 THEN COUNT=COUNT+3: THREE=THREE+1: GOTO 1890
1820 IF CARD=4 OR CARD=17 OR CARD=30 OR CARD=43 THEN COUNT=COUNT+4: FOUR=FOUR+1: GOTO 1890
1830 IF CARD=5 OR CARD=18 OR CARD=31 OR CARD=44 THEN COUNT=COUNT+5: FIVE=FIVE+1: GOTO 1890
1840 IF CARD=6 OR CARD=19 OR CARD=32 OR CARD=45 THEN COUNT=COUNT+6: SIX=SIX+1: GOTO 1890
1850 IF CARD=7 OR CARD=20 OR CARD=33 OR CARD=46 THEN COUNT=COUNT+7: SEVEN=SEVEN+1: GOTO 1890
1860 IF CARD=8 OR CARD=21 OR CARD=34 OR CARD=47 THEN COUNT=COUNT+8: EIGHT=EIGHT+1: GOTO 1890
1870 IF CARD=9 OR CARD=22 OR CARD=35 OR CARD=48 THEN COUNT=COUNT+9: NINE=NINE+1: GOTO 1890
1880 COUNT=COUNT+10: TEN=TEN+1
1890 IF COUNT>21 AND ACE THEN COUNT=COUNT-10:DDTOTAL=0: ACE=ACE-1
1900 BUST = FALSE
1910 IF COUNT>21 THEN BUST = 1	    'SET BUST TO TRUE
1920 RETURN
1930 REM **********************************
1940 REM **  DRAWING THE FACE OF A CARD  **
1950 REM **********************************
1960 COLOR 1,7: LOCATE ROW,COL: PRINT CHR$(201) + STRING$(3,203) + CHR$(187)
1970 FOR I=1 TO 5
1980	LOCATE ROW+I,COL: PRINT CHR$(204) + STRING$(3,206) + CHR$(185)
1990 NEXT
2000 LOCATE ROW+6,COL: PRINT CHR$(200) + STRING$(3,202) + CHR$(188)
2010 PLAY "L64O1D-"
2020 RETURN
2030 REM ***************************
2040 REM **  SPLITTING OF A HAND  **
2050 REM ***************************
2060 REM MOVE CARD TWO TO THE RIGHT SIDE OF THE SCREEN
2070 NBRCDSP = 1:FIRST=1
2080 FOR I=15 TO 21
2090	LOCATE I,5:COLOR BAKGRD: PRINT SPACE$(5)
2100 NEXT
2105 LOCATE 23,8:COLOR BAKGRD:PRINT SPACE$(31);
2110 ROW=15: COL=32: CARD=PCARD(2): PCARD(10)=CARD: GOSUB 3450
2120 REM **  now deal another card to hand 1  **
2130 ROW=15: COL=5
2140 IF CARDNBR>47 THEN Z5=1:GOSUB 3280
2150 CARDNBR=CARDNBR+1
2160 NBRCDSP=NBRCDSP+1
2170 CARD=DECK(CARDNBR): PCARD(NBRCDSP)=CARD
2180 GOSUB 3450 : IF FIRST<>1 THEN 2240       'DISPLAY THE CARD
2190 REM **  now deal another card to hand 2  **
2200 IF CARDNBR>47 THEN Z5=1:GOSUB 3280
2210 CARDNBR=CARDNBR+1
2220 CARD=DECK(CARDNBR): PCARD(11)=CARD
2230 COL=36: GOSUB 3450: COL=5
2240 COUNT = 0
2250 ACE = FALSE
2260 FOR CNT=1 TO NBRCDSP
2270	CARD = PCARD(CNT)
2280	GOSUB 1760
2290    IF BUST THEN COLOR SECTXT,BAKGRD: LOCATE 23,2: PRINT COUNT;: COUNT=-1:          IF SPLIT=1 THEN LOCATE 24,1:COLOR SECTXT:PRINT "Mayor a 21";:GOTO 2360            ELSE GOTO 2360
2300 NEXT
2305 IF ACE>0 THEN DDTOTAL=COUNT-10 ELSE DDTOTAL=0
2310 GOSUB 12000
2320 LOCATE 22,8: COLOR BAKGRD,BAKGRD: PRINT SPACE$(22);: LOCATE 23,8: PRINT SPACE$(22);
2325 IF NBRCDSP>=2 AND COUNT=21 THEN DDTOTAL=0:GOSUB 12000:FOR I=1 TO 1000:NEXT:GOTO 2370
2330 COLOR SECTXT,BAKGRD: LOCATE 22,8: PRINT "C=CARTA B=BASTA?   ";
2335 LOCATE 22,23: COLOR TRITXT: PRINT "       ";: LOCATE 22,23,1: GOSUB 2840
2340 IF ANS$="C" OR ANS$="c" THEN COL=COL+4: FIRST=0: GOTO 2140
2350 IF ANS$<>"B" AND ANS$<>"b" THEN SOUND 400,4:GOTO 2335
2360 REM **  now play the right hand  **
2370 FIRST=0
2380 SPLIT=SPLIT-1: COL=COL+6
2390 IF SPLIT<1 THEN SPLIT=1: TOTLP2=COUNT:DDTOTAL=0:IF COUNT=-1 THEN RETURN ELSE GOSUB 12000: RETURN
2400 LOCATE 22,30: COLOR SECTXT,BAKGRD: PRINT "1era. Mano";: LOCATE 23,33: PRINT "Total";: LOCATE 24,33: IF COUNT<1 THEN PRINT "QUEBRO"; ELSE PRINT COUNT;
2410 LOCATE 22,8: COLOR BAKGRD,BAKGRD: PRINT SPACE$(20);
2420 FOR J=15 TO 21: LOCATE J,1: PRINT SPACE$(40);: NEXT
2430 CARD=PCARD(10): COL=1: GOSUB 3450: COL=COL+4: CARD=PCARD(11): GOSUB 3450
2440 PCARD(1)=PCARD(10): PCARD(2)=PCARD(11)
2450 TOTLP1=COUNT: NBRCDSP=2: GOTO 2240
2460 REM **************************************************
2470 REM **  SOUND THE SIREN IF PLAYER GETS A BLACKJACK  **
2480 REM **************************************************
2490 FOR J=1 TO 12
2500	FOR I=2 TO 5
2510		PLAY "MBL64T255O=I;EFF#"
2520	NEXT
2530	LOCATE 24,10: COLOR FORTXT,BAKGRD,BAKGRD: PRINT " B L A C K J A C K ";
2540    LOCATE 25,16,0: PRINT "UD GANA";
2550	FOR I=4 TO 1 STEP -1
2560		PLAY "MBL64T255O=I;F#FE"
2570	NEXT
2580 NEXT
2590 RETURN
2600 REM *************************************************
2610 REM **  SOUND THE HORN IF DEALER GETS A BLACKJACK	**
2620 REM *************************************************
2630 LOCATE 5,11: COLOR FORTXT,BAKGRD: PRINT "B L A C K J A C K "
2640 FOR I=1 TO 15
2650	PLAY "MBL64T255O0ABABABAB"
2660 NEXT
2670 RETURN
2680 REM ******************************************
2690 REM **  SOUND EFFECTS FOR THE DECK SHUFFLE  **
2700 REM ******************************************
2710 PLAY "MBL50T255O1CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40CP40"
2720 PLAY "MBP10O0DP4DP4DP4DP1"
2730 RETURN
2740 REM ********************************
2750 REM **  DISPLAY THE BUST MESSAGE  **
2760 REM ********************************
2770 COLOR FORTXT,BAKGRD,BAKGRD
2780 IF BLACKJACKD OR BLACKJACKP THEN GOTO 2790 ELSE IF BST=0 THEN LOCATE 6,8: PRINT "    MAYOR  DE  21       " ELSE LOCATE 25,12: PRINT " MAYOR DE 21    ";
2790 COLOR SECTXT,BAKGRD,BAKGRD
2800 RETURN
2810 REM ***************************
2820 REM **  INPUTTING AN ANSWER  **
2830 REM ***************************
2840 COLOR TRITXT
2850 ANS$=INKEY$: IF ANS$<>"" THEN 2850
2860 ANS$=INKEY$: IF ANS$=""  THEN 2860
2870 RETURN
2880 REM *************************
2890 REM **  INPUTTING THE BET	**
2900 REM *************************
2910 BET=0
2920 COLOR TRITXT
2930 BET$=INKEY$: IF BET$<>"" THEN 2930
2940 BET$=INKEY$: IF BET$=""  THEN 2940
2950 IF BET$=CHR$(27) THEN PRINT "Esc";: CHAIN"rstart",420
2960 IF BET$=CHR$(13) THEN RETURN
2970 IF BET$="M" OR BET$="m" THEN IF BET>0 THEN GOTO 3020 ELSE BET=10: PRINT "10": RETURN
2980 IF BET$<>"P" AND BET$<>"p" THEN 3000
2983 IF PEOPLE=1 THEN 3020
2985 CURRENT=CURRENT+1: IF CURRENT>PEOPLE THEN CURRENT=1
2990 GOSUB 3110: GOTO 340
3000 IF ASC(BET$)=8 OR BET$=CHR$(0)+CHR$(75) THEN IF BET=0 THEN 3020 ELSE WHERE=POS(0): LOCATE 16,WHERE-1,0: BET=INT(BET/10): PRINT " ";: LOCATE 16,WHERE-1,1: GOTO 2940
3010 IF BET$>="0" AND BET$<="9" THEN 3030
3020 SOUND 400,4: GOTO 2940
3030 NUMBER=VAL(BET$)
3040 IF NUMBER=0 THEN IF BET=0 THEN 3020
3050 IF BET*10+NUMBER>999999! THEN LOCATE 20,7,0: SOUND 400,4:  PRINT "Pruebe de nuevo, "NAM$(CURRENT)".";: FOR I=1 TO 1500: NEXT: LOCATE 20,1: PRINT SPACE$(39);: GOTO 405
3060 BET=BET*10+NUMBER: PRINT BET$;: GOTO 2940
3070 REM **************************
3080 REM **  DISPLAYING THE BET  **
3090 REM **************************
3100 COLOR PRMTXT: LOCATE 4,1,0: PRINT "CARTAS DE LA BANCA": COLOR SECTXT: LOCATE 4,22: PRINT "Su apuesta";: VALU=AMO: GOSUB 3960: PRINT "$"A$: RETURN
3110 REM *************************************
3120 REM **  UPDATING THE PLAYERS' AMOUNTS  **
3130 REM *************************************
3140 ON PEOPLE GOTO 3141,3142,3143,3144
3141 ST=17:SKIP=0:GOTO 3150
3142 ST=9:SKIP=16:GOTO 3150
3143 ST=5:SKIP=12:GOTO 3150
3144 ST=2:SKIP=10
3150 COLOR BAKGRD: LOCATE 1,1: PRINT SPACE$(40):LOCATE 2,1:PRINT SPACE$(40)
3170 FOR I=1 TO PEOPLE
3180	IF CURRENT=I THEN COLOR SECTXT ELSE COLOR PRMTXT
3190	LOCATE 1,ST,0: PRINT NAM$(I)
3191	LOCATE 2,ST,0:VALU=PLAYER(I):GOSUB 3960:PRINT "$"A$:ST=ST+SKIP
3193 NEXT
3220 RETURN
3230 REM **************************
3240 REM **  SHUFFLING THE DECK  **
3250 REM **************************
3260 LOCATE 15,10: COLOR PRMTXT: PRINT "Por favor espere un segundo"
3270 LOCATE 16,10,0: PRINT "mientras mezclo las cartas"
3280 FOR I=1 TO 52
3290	DECK(I) = 0
3300 NEXT
3310 GOSUB 2710
3320 CARDNBR = 1   'BURY THE FIRST CARD
3330 FOR I=1 TO 52
3340	CARD=INT(RND*52)+1
3350	IF DECK(CARD)<>0 GOTO 3340
3360	DECK(CARD) = I
3370	IF I=50 THEN GOSUB 2710
3380 NEXT
3385 FOR I=1 TO 52
3386 IF DECK(I)=0 THEN 3280
3387 NEXT
3390 FOR I=1 TO 800: NEXT I
3395 IF Z5=1 THEN 3405
3400 GOSUB 3900
3405 Z5=0
3410 RETURN
3420 REM ******************************
3430 REM **  DRAWING FACE OF A CARD  **
3440 REM ******************************
3450 COLOR 1,7: LOCATE ROW,COL,0: PRINT CHR$(201) + STRING$(3,205) + CHR$(187)
3460 FOR RW=ROW+1 TO ROW+5
3470	LOCATE RW,COL,0: PRINT CHR$(186): LOCATE RW,COL+1,0: COLOR 7,7: PRINT		 STRING$(3,176): LOCATE RW,COL+4,0: COLOR 1,7: PRINT CHR$(186)
3480 NEXT RW
3490 LOCATE ROW+6,COL,0: PRINT CHR$(200) + STRING$(3,205) + CHR$(188)
3500 IF PRMTXT=7 THEN CL2=0 ELSE CL2=4
3510 IF CARD<14 THEN LOCATE ROW+1,COL+1,0: COLOR 0,7: PRINT CHR$(6): LOCATE ROW+5,COL+3,0: PRINT CHR$(6)      'spades
3520 IF (CARD>13) AND (CARD<27) THEN LOCATE ROW+1,COL+1,0: COLOR CL2,7: PRINT CHR$(3): LOCATE ROW+5,COL+3,0: PRINT CHR$(3)     'hearts
3530 IF (CARD>26) AND (CARD<40) THEN LOCATE ROW+1,COL+1,0: COLOR 0,7: PRINT CHR$(5): LOCATE ROW+5,COL+3,0: PRINT CHR$(5)     'clubs
3540 IF CARD>39 THEN LOCATE ROW+1,COL+1,0: COLOR CL2,7: PRINT CHR$(4): LOCATE ROW+5,COL+3,0: PRINT CHR$(4)	'diamonds
3545 IF PRMTXT=10 THEN COLOR 0:GOTO 3550
3547 IF PRMTXT=7 THEN COLOR 0
3550 LOCATE ROW+3,COL+1,0
3560 IF (CARD=11) OR (CARD=24) OR (CARD=37) OR (CARD=50) THEN PRINT " J ": GOTO 3690
3570 IF (CARD=12) OR (CARD=25) OR (CARD=38) OR (CARD=51) THEN PRINT " Q ": GOTO 3690
3580 IF (CARD=13) OR (CARD=26) OR (CARD=39) OR (CARD=52) THEN PRINT " K ": GOTO 3690
3590 IF (CARD=1) OR (CARD=14) OR (CARD=27) OR (CARD=40) THEN PRINT " A " : GOTO 3690
3600 IF (CARD=2) OR (CARD=15) OR (CARD=28) OR (CARD=41) THEN PRINT " 2 " : GOTO 3690
3610 IF (CARD=3) OR (CARD=16) OR (CARD=29) OR (CARD=42) THEN PRINT " 3 " : GOTO 3690
3620 IF (CARD=4) OR (CARD=17) OR (CARD=30) OR (CARD=43) THEN PRINT " 4 " : GOTO 3690
3630 IF (CARD=5) OR (CARD=18) OR (CARD=31) OR (CARD=44) THEN PRINT " 5 " : GOTO 3690
3640 IF (CARD=6) OR (CARD=19) OR (CARD=32) OR (CARD=45) THEN PRINT " 6 " : GOTO 3690
3650 IF (CARD=7) OR (CARD=20) OR (CARD=33) OR (CARD=46) THEN PRINT " 7 " : GOTO 3690
3660 IF (CARD=8) OR (CARD=21) OR (CARD=34) OR (CARD=47) THEN PRINT " 8 " : GOTO 3690
3670 IF (CARD=9) OR (CARD=22) OR (CARD=35) OR (CARD=48) THEN PRINT " 9 " : GOTO 3690
3680 IF (CARD=10) OR (CARD=23) OR (CARD=36) OR (CARD=49) THEN PRINT " 10"
3690 PLAY "L64O1D-"
3700 RETURN
3710 REM **************************************
3720 REM **  INPUTTING THE INSURANCE AMOUNT  **
3730 REM **************************************
3740 LOCATE 22,13: COLOR BAKGRD: PRINT SPACE$(27);
3750 LOCATE 22,13: COLOR PRMTXT: PRINT "En cuanto asegura     ";: LOCATE 23,13: PRINT "(Hasta $";: IF PLAYER(CURRENT)<INT(BET/2) THEN VALU=PLAYER(CURRENT) ELSE VALU=INT(BET/2)
3760 GOSUB 3960: PRINT A$")? ";: COLOR TRITXT: PRINT "          ";: LOCATE 23,29,1
3780 INS=0
3790 ANS$=INKEY$: IF ANS$<>"" THEN 3790
3800 ANS$=INKEY$: IF ANS$=""  THEN 3800
3810 IF ANS$=CHR$(13) THEN IF POS(0)=29 THEN SOUND 400,4: GOTO 3800 ELSE RETURN
3820 IF ASC(ANS$)=8 OR ANS$=CHR$(0)+CHR$(75) THEN IF INS=0 THEN SOUND 400,4: GOTO 3800 ELSE WHERE=POS(0): LOCATE 23,WHERE-1,0: INS=INT(INS/10): PRINT " ";: LOCATE 23,WHERE-1,1: GOTO 3800
3830 IF ANS$<"0" OR ANS$>"9" THEN SOUND 400,4: GOTO 3800
3840 NUMB=VAL(ANS$)
3845 IF NUMB=0 THEN IF POS(0)>29 AND INS=0 THEN SOUND 400,4: GOTO 3800
3850 IF INS*10+NUMB>999999! THEN LOCATE 25,13,0: SOUND 400,4: PRINT "Pruebe de nuevo "NAM$(CURRENT)".";: FOR I=1 TO 1500: NEXT: LOCATE 25,13: PRINT SPACE$(23);: GOTO 3740
3860 PRINT ANS$;: INS=INS*10+NUMB: GOTO 3800
3870 REM ***********************************************
3880 REM **  ERASING THE SCREEN AT LINES 15, 16 & 17  **
3890 REM ***********************************************
3900 COLOR BAKGRD: LOCATE 15,1,0: PRINT SPACE$(40)
3910 LOCATE 16,1,0: PRINT SPACE$(40): LOCATE 17,1,0: PRINT SPACE$(40)
3920 RETURN
3930 REM **********************************************
3940 REM **  REMOVING THE SIGN FROM A DOLLAR AMOUNT  **
3950 REM **********************************************
3960 A$=STR$(VALU)
3970 A$=RIGHT$(A$,LEN(A$)-1)
3980 RETURN
9999 SAVE"blacmar1":PRINT "Blacmar1.bas Rescatado":END
12000 COLOR PRMTXT,BAKGRD:LOCATE 22,2,0:PRINT "TOTAL";:LOCATE 23,2,0:COLOR SECTXT,BAKGRD:IF BLACKJACKP=TRUE THEN PRINT COUNT;:RETURN
12010 IF DDTOTAL=0 THEN PRINT COUNT;:LOCATE 24,2,0:PRINT "   ";:LOCATE 25,2,0:PRINT "   "; ELSE PRINT DDTOTAL;:LOCATE 24,3,0:PRINT "or";:LOCATE 25,2,0:PRINT COUNT;
12020 RETURN
